//
//  QR_CodeViewController.m
//  OtherDemo
//
//  Created by lianjie on 2018/7/23.
//  Copyright © 2018年 lianjie. All rights reserved.
//

#import "DEWQR_CodeViewController.h"
#import "DEWInviteCodeController.h"

@interface DEWQR_CodeViewController ()<UITableViewDelegate,UITableViewDataSource>
/**  */
@property (strong, nonatomic) UITableView *tableView;
@end

@implementation DEWQR_CodeViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    [self loadData];
    
    [self createView];
    
}

#pragma mark ----RequestData
-(void)loadData
{
    
    
}


#pragma mark ----initView
-(void)createView
{
    self.navigationItem.title = @"被邀请人信息";
    
    [self creatTab];
    
}

-(void)creatTab{
    _tableView = [[UITableView alloc]initWithFrame:CGRectMake(0, 0, DEWScreenWidth , DEWScreenHeight - NAVH) style:UITableViewStyleGrouped];
    _tableView.delegate = self;
    _tableView.dataSource = self;
    _tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
    [self.view addSubview:_tableView];
    if (@available(iOS 11.0, *)){
        _tableView.contentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentNever;
        self.tableView.estimatedRowHeight = 0;
        self.tableView.estimatedSectionHeaderHeight = 0;
        self.tableView.estimatedSectionFooterHeight = 0;
    }
}

-(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
    return 3;
}
-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    if (section == 0) {
        return 1;
    }else if (section == 1){
        return 2;
    }else{
        return 1;
    }
    
}
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    NSString *cellID = [NSString stringWithFormat:@"QR_Code%ld%ld",(long)indexPath.section,(long)indexPath.row];
    UITableViewCell *cell = nil;
    cell = [[UITableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellID];
    cell.selectionStyle = UITableViewCellSelectionStyleNone;
    
    if (indexPath.section == 0 && indexPath.row == 0) {
        UIImageView *AddressimageView = [[UIImageView alloc]initWithFrame:CGRectMake(15, 17, 13, 16)];
        AddressimageView.image = [UIImage imageNamed:@"地址"];
        [cell addSubview:AddressimageView];
        
        UILabel *addressLabel = [[UILabel alloc]init];
        addressLabel.frame = CGRectMake(AddressimageView.right + 7, 15, DEWScreenWidth - 35, 21);
        addressLabel.text = @"所在小区：江林新城1期（仅可邀请您的邻居哦~）";
        addressLabel.textColor = Color_99;
        addressLabel.font = [UIFont systemFontOfSize:15];
        [cell addSubview:addressLabel];
        
    }
    if (indexPath.section == 1) {
        NSArray *arr = @[@"TA的身份",@"TA的楼号"];
        
        UILabel *titleL = [[UILabel alloc]init];
        titleL.frame = CGRectMake(10, 15, 100, 20);
        titleL.text = arr[indexPath.row];
        titleL.textColor = Color_33;
        titleL.font = [UIFont systemFontOfSize:15];
        [cell addSubview:titleL];
        
        UILabel *subL = [[UILabel alloc]init];
        subL.frame = CGRectMake(120, 15,DEWScreenWidth - 160 , 20);
        subL.text = @"业主";
        subL.textColor = Color_33;
        subL.font = [UIFont systemFontOfSize:15];
        subL.textAlignment = NSTextAlignmentRight;
        [cell addSubview:subL];
        cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
    }
    if (indexPath.section == 2) {
        UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
        button.frame = CGRectMake(15, 40, DEWScreenWidth - 30, 40);
        [button setTitle:@"生成二维码" forState:UIControlStateNormal];
        [button setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
        [button addTarget:self action:@selector(buttonClick:) forControlEvents:UIControlEventTouchUpInside];
        [button setBackgroundColor:UIColorFromRGB(0xFF8900)];
        button.layer.cornerRadius = 4;
        cell.backgroundColor = [UIColor clearColor];
        [cell addSubview:button];
    }
    return cell;
}
-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
    if (indexPath.section == 2) {
        return 80;
    }
    return 50;
}
-(CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section{
    return 0.001;
}
-(CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section{
    return 0.001;
}
-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
    [tableView deselectRowAtIndexPath:indexPath animated:NO];
}
#pragma mark - 生成二维码
-(void)buttonClick:(UIButton *)sender{
    NSLog(@"点击生成二维码");
    DEWInviteCodeController *code = [[DEWInviteCodeController alloc]init];
    [self.navigationController pushViewController:code animated:YES];
}
#pragma mark ---lazy
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
